﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Credisoft.Models.Helpers;
using Credisoft.Models.Credisoft_DAO;
using Credisoft.Models;
using Credisoft.Models.Credisoft_BO;
namespace Credisoft.Controllers.Inbox
{
    public class InboxController : Controller
    {
        //
        // GET: /Inbox/

        public ActionResult Inbox()
        {
            return View();
        }


        public ActionResult ApprovalFormModal()
        {
            object model = null;
            var obj = new { view = RequestHelper.PartialView(this, "ApprovalFormModal", model)};
            return Json(obj);
        }

       //Aqui se recibe si la solicitud ha sido aprobada o rechazada
        public Boolean ApprovalFormAnswer(int idAnswer,int idRequest, int idUser)
        {
        

            return true;
        }




        public ActionResult CreditRequestAsignationModal(int idRequest, int idGroupChief)
        {
            return null;
            ////object model = new ModeloPruebaTopo(); // whatever you want baybeeee
            //WorkgroupDAO workgroupDAO = new WorkgroupDAO();
            //UserDAO userDAO = new UserDAO();
            ////grupotrabajo workgroup = workgroupDAO.getWordgroupByChief(idGroupChief);
            //this.ViewBag.workgroup = workgroup;
            ////List<usuario> memberList = workgroupDAO.getMembers(workgroup.idgrupotrabajo);
            //memberList.RemoveAt(0);
            //List<double> workloads = new double[5].ToList();
            //int counter = 1;
            //foreach (var user in memberList)
            //{
            //    workloads.Insert(counter,userDAO.getWorkLoad(user)); 
            //    counter++;
            //}
            //this.ViewBag.memberList = memberList;
            //this.ViewBag.workloads = workloads;
            //object model = null;
            //var obj = new { view = RequestHelper.PartialView(this, "CreditRequestAsignationModal", model) };
            //return Json(obj);
        }

        public ActionResult UpdateMailbox2()
        {
            CreditGrantingDAO creditGrantingDAO = new CreditGrantingDAO();
            //List<otorgamiento> grantingList = creditGrantingDAO.getCreditGrantingData();
            EnterpriseDAO enterpriseDAO = new EnterpriseDAO();
            List<EnterpriseBO> enterpriseBOList = new List<EnterpriseBO>();
            EconomicGroupDAO economicGroupDAO = new EconomicGroupDAO();
            List<EconomicGroupBO> economicGroupBOList = new List<EconomicGroupBO>();
            var objList = new List<object>();

            int j = 0;
            //foreach (var i in grantingList)
            //{
            //    enterpriseBOList.Add(enterpriseDAO.getEnterpriseData((int)i.identidad));
            //    int groupId = enterpriseBOList.ElementAt(j).groupId;
            //    economicGroupBOList.Add(economicGroupDAO.getEconomicGroupData(enterpriseBOList.ElementAt(j).groupId));
            //    var obj = new
            //    {
            //        //requestId = grantingList.ElementAt(j).idotorgamiento,
            //        //socialReason = enterpriseBOList.ElementAt(j).socialReason,
            //        //group = economicGroupBOList.ElementAt(j).name,
            //        //recordDate = grantingList.ElementAt(j).fecharegistro
            //    };
            //    j++;
            //    objList.Insert(0, obj);
            //}
            //EnterpriseBO enterpriseBO = enterpriseDAO.getEnterpriseData((int)grantingList.identidad);
            //EconomicGroupBO economicGroupBO = economicGroupDAO.getEconomicGroupData(enterpriseBO.groupId);
            //var obj = new { requestId = grantingList.idsolicitud, socialReason = enterpriseBO.socialReason, group = economicGroupBO.name, recordDate = grantingList.fecharegistro};
            return Json(objList);
        }
    }
}
